CXXFLAGS = -g -Wall -rdynamic -march=native --std=c++11  -I../include -L../lib 
CXXFLAGS += -O0

TESTS = echo discard daytime time timeclient chargen chargenclient all_in_one \
        finger01 finger02 finger03 finger04 finger05 finger06 \
        download download2 download3 \
        chatclient chatserver \
        maxconnection \
        timer2 timer3 timer4 timer5 timer6 \
        nettydiscards nettydiscardc nettyechos nettyechos2 nettyechoc \
        roundtrip \
        idleconn1 idleconn2 \

all: $(TESTS)

$(TESTS):
	mkdir bin -p
	g++ $(CXXFLAGS) -o bin/$@ $(filter %.cc,$^) $(LDFLAGS) -lmuduo_net_cpp11 -lmuduo_base_cpp11 -lpthread

echo: simple/echo/echo.cc simple/echo/main.cc
discard: simple/discard/discard.cc simple/discard/main.cc
daytime: simple/daytime/daytime.cc simple/daytime/main.cc
time: simple/time/time.cc simple/time/main.cc
timeclient: simple/timeclient/timeclient.cc
chargen: simple/chargen/chargen.cc simple/chargen/main.cc
chargenclient: simple/chargenclient/chargenclient.cc
all_in_one: simple/echo/echo.cc simple/discard/discard.cc simple/daytime/daytime.cc simple/time/time.cc simple/chargen/chargen.cc \
	simple/all_in_one/all_in_one.cc

finger01: finger/finger01.cc
finger02: finger/finger02.cc
finger03: finger/finger03.cc
finger04: finger/finger04.cc
finger05: finger/finger05.cc
finger06: finger/finger06.cc

download: filetransfer/download.cc
download2: filetransfer/download2.cc
download3: filetransfer/download3.cc

chatclient: asio/chat/client.cc
chatserver: asio/chat/server.cc

maxconnection: maxconnection/echo.cc maxconnection/main.cc

timer2: asio/tutorial/timer2/timer.cc
timer3: asio/tutorial/timer3/timer.cc
timer4: asio/tutorial/timer4/timer.cc
timer5: asio/tutorial/timer5/timer.cc
timer6: asio/tutorial/timer6/timer.cc

nettydiscards: netty/discard/server.cc
nettydiscardc: netty/discard/client.cc
nettyechos: netty/echo/server.cc
nettyechos2: netty/echo/server2.cc
nettyechoc: netty/echo/client.cc

roundtrip: roundtrip/roundtrip.cc

idleconn1: idleconnection/echo.cc idleconnection/main.cc
idleconn1: CXXFLAGS += --std=c++03 
idleconn2: idleconnection/sortedlist.cc

clean:
	rm -rf bin
